package com.caiyouxi.boss.buser.controller;

import com.caiyouxi.boss.buser.model.SysRightsBean;
import com.caiyouxi.boss.buser.service.SysRightsService;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.control.BaseController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2017/10/30.
 */
@RestController
@RequestMapping("/boss/rights")
public class SysRightsController extends BaseController {

    private Logger logger = Logger.getLogger(SysRightsController.class);

    @Autowired
    private SysRightsService sysRightsService;

    //获取权限列表
    @RequestMapping("/get_list")
    public ResData get_rights_list(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("获取所有的列表");
        return sysRightsService.get_right_list(bean);
    }

    //添加权限列表
    @RequestMapping("/add_rights")
    public ResData add_rights(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("添加权限信息");
        return sysRightsService.add_rights(bean);
    }

    //获取权限信息
    @RequestMapping("/get_right_info")
    public ResData get_right_info(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("获取权限信息");
        return sysRightsService.get_right_info(bean);
    }

    //修改权限信息
    @RequestMapping("/update_rights")
    public ResData update_rights(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("修改权限信息");
        return sysRightsService.update_rights(bean);
    }

    //删除权限信息
    @RequestMapping("/delete_rights")
    public ResData delete_rights(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("删除权限信息");
        return sysRightsService.delete_rights(bean);
    }

    //通过权限id查询角色信息
    @RequestMapping("/get_right_role_list")
    public ResData get_right_role_list(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("get_right_role_list");
        return sysRightsService.get_right_role_list(bean);
    }

    //更新角色信息
    @RequestMapping("/update_roles_rights")
    public ResData update_role_rights(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        logger.info("update_roles_rights");
        return sysRightsService.update_role_right(bean);
    }

    //通过权限id查询拥有此权限的用户信息
    @RequestMapping("/get_right_user_list")
    public ResData get_right_user_list(HttpServletRequest request, HttpServletResponse response,  SysRightsBean bean){
        return sysRightsService.get_right_user_list(bean);
    }

    //添加用户权限信息
    @RequestMapping("/update_user_right_info")
    public ResData update_user_right_info(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRightsBean bean){
        return sysRightsService.update_user_right_info(bean);
    }

}
